Skip to content

fix(doctor): resolve settings-json and hooks-claude-count false positives - #821

Open
flaviohtavares wants to merge 2 commits into
SynkraAI:mainfrom
flaviohtavares:fix/doctor-check-false-positives
Open

fix(doctor): resolve settings-json and hooks-claude-count false positives#821
flaviohtavares wants to merge 2 commits into
SynkraAI:mainfrom
flaviohtavares:fix/doctor-check-false-positives

Conversation

@flaviohtavares

@flaviohtavares flaviohtavares commented Aug 10, 2026

Copy link
Copy Markdown

Summary

Two aiox doctor checks warn on a healthy framework checkout. Both are checker gaps rather than install problems — a freshly cloned, fully installed repo reports 16 PASS / 2 WARN when it should report 18 PASS / 0 WARN.

settings-json

The check required >= 40 deny rules unconditionally and never consulted boundary.frameworkProtection. Contributors set that flag to false precisely so L1/L2 paths stay editable — this repo ships it as false in core-config.yaml — which makes an empty deny list the correct state, not a misconfiguration.

It now reads the flag and returns PASS when protection is off. The gate sits before both the deny-count test and the boundary-alignment test, so neither fires in contributor mode. Parsing is line-based to match the file's existing no-YAML-dependency style, and scoped to the boundary: section so an unrelated key elsewhere can't be picked up. It defaults to protected when the config file or the key is absent, so project installs are unaffected.

hooks-claude-count

The check inspected only settings.local.json. This repo registers its hooks in settings.json, which Claude Code merges equally, so all five .cjs files were reported unregistered while actually being wired up and firing.

It now collects hook commands from both files. The message reports how many of the discovered files are referenced (5 hook files found, 3 registered) rather than implying all must be — the engine hooks are spawned as child processes by their wrappers (synapse-wrapper.cjs:23, precompact-wrapper.cjs:17) to isolate stdout/stderr, so registering them directly would break that isolation.

Note that "fixing" this by duplicating the registrations into settings.local.json would be actively harmful: Claude Code merges both files, so every hook would fire twice per event.

Tests

8 new cases, 59 total in doctor-checks.test.js. Verified 5 fail against the unpatched checks; the other 3 are regression guards covering protected-by-default, explicit frameworkProtection: true, and malformed-JSON tolerance.

Verification

  • npx jest packages/installer/tests/unit/doctor/doctor-checks.test.js — 59/59
  • ESLint clean on all three files
  • aiox doctor — 18 PASS / 0 WARN / 0 FAIL, was 16 PASS / 2 WARN

No behaviour change for project installs, where frameworkProtection is true and hooks live in settings.local.json.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved hook registration checks across standard and local settings files.
    • Added safer handling for missing or malformed settings.
    • Hook checks now recognize exact filenames and provide clearer registration counts and warnings.
  • New Features

    • Contributor mode can disable framework protection checks through configuration.
    • When disabled, boundary and deny-rule enforcement is skipped as expected.
    • Framework protection remains enabled by default when not configured.

…ives

Both checks warned on a healthy framework checkout:

- settings-json required >= 40 deny rules unconditionally, ignoring
  boundary.frameworkProtection. Contributors set it to false precisely so
  L1/L2 paths stay editable, making an empty deny list correct in that mode.
  Now reads the flag and PASSes when protection is off; defaults to
  protected when the config or key is absent.

- hooks-claude-count only inspected settings.local.json, but this repo
  registers its hooks in settings.json, which Claude Code merges equally.
  Now collects commands from both files and reports how many of the
  discovered .cjs files are referenced, since engine hooks are spawned by
  their wrappers rather than registered directly.

aiox doctor goes from 16 PASS / 2 WARN to 18 PASS / 0 WARN with no
behaviour change for project installs.

Tests: 8 new cases (59 total). Verified 5 of them fail against the
unpatched checks; the other 3 are regression guards for the
protected-by-default, explicit-true, and malformed-JSON paths.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@flaviohtavares is attempting to deploy a commit to the SINKRA - AIOX Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to aiox-core! Thanks for your first pull request.

What happens next?

  1. Automated checks will run on your PR
  2. A maintainer will review your changes
  3. Once approved, we'll merge your contribution!

PR Checklist:

Thanks for contributing!

@github-actions github-actions Bot added type: test Test coverage and quality area: core Core framework (.aios-core/core/) area: installer Installer and setup (packages/installer/) area: docs Documentation (docs/) labels Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fb66699c-f042-4d24-a07b-9b2513776875

📥 Commits

Reviewing files that changed from the base of the PR and between 3691db8 and f64baa8.

📒 Files selected for processing (3)
  • .aiox-core/core/doctor/checks/hooks-claude-count.js
  • .aiox-core/install-manifest.yaml
  • packages/installer/tests/unit/doctor/doctor-checks.test.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • .aiox-core/install-manifest.yaml
  • packages/installer/tests/unit/doctor/doctor-checks.test.js
  • .aiox-core/core/doctor/checks/hooks-claude-count.js

Walkthrough

The doctor checks now read framework protection settings, support contributor mode, and inspect Claude hooks in both settings.json and settings.local.json. Unit tests cover configuration defaults, registration scenarios, malformed files, and updated install metadata.

Changes

Doctor checks

Layer / File(s) Summary
Framework protection mode
.aiox-core/core/doctor/checks/settings-json.js, packages/installer/tests/unit/doctor/doctor-checks.test.js, .aiox-core/install-manifest.yaml
The settings check reads boundary.frameworkProtection. Contributor mode returns PASS without boundary enforcement. Tests cover enabled, disabled, and missing configuration.
Claude hook registration detection
.aiox-core/core/doctor/checks/hooks-claude-count.js, packages/installer/tests/unit/doctor/doctor-checks.test.js, .aiox-core/install-manifest.yaml
The hook check parses both Claude settings files, handles invalid files, and reports registration status. Tests cover direct hooks, wrapper hooks, missing registrations, and malformed JSON.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HookCheck as hooks-claude-count.js
  participant Settings as settings.json
  participant LocalSettings as settings.local.json
  HookCheck->>Settings: collectHookCommands
  HookCheck->>LocalSettings: collectHookCommands
  Settings-->>HookCheck: registered hook commands
  LocalSettings-->>HookCheck: registered hook commands
  HookCheck-->>HookCheck: report registration status
Loading

Possibly related PRs

Suggested reviewers: oalanicolas

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies both doctor checks and states that the change fixes their false positives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aiox-core/core/doctor/checks/hooks-claude-count.js:
- Around line 104-106: Update the hook filename matching in the referencedCount
calculation to require the complete .cjs filename at a command path or
shell-token boundary, rather than matching substrings or stripping the
extension. Preserve valid path references and add a regression test covering
similarly named hook files such as sync.cjs and sync-wrapper.cjs.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 766503bc-125c-4ec9-a1b7-660d58666362

📥 Commits

Reviewing files that changed from the base of the PR and between 0b32b68 and 3691db8.

📒 Files selected for processing (4)
  • .aiox-core/core/doctor/checks/hooks-claude-count.js
  • .aiox-core/core/doctor/checks/settings-json.js
  • .aiox-core/install-manifest.yaml
  • packages/installer/tests/unit/doctor/doctor-checks.test.js

Comment thread .aiox-core/core/doctor/checks/hooks-claude-count.js Outdated
Substring matching treated sync.cjs as registered when a command only
referenced sync-wrapper.cjs, so a missing registration could produce a
PASS with an inflated registered count.

Commands are now tokenized: quotes and trailing shell punctuation are
stripped, Windows separators normalized, and only complete .cjs
basenames count as a reference.

Addresses CodeRabbit review on SynkraAI#821.

Tests: 3 new cases (62 total) — similarly named files, suffix-only
references, and quoted/backslashed paths. Verified the first two fail
against the previous substring matching.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core framework (.aios-core/core/) area: docs Documentation (docs/) area: installer Installer and setup (packages/installer/) type: test Test coverage and quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant